<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!--{include file='comm/header.tpl'}-->
    <!--{include file='comm/comm_cal.tpl'}-->
    <title>客户投诉列表</title>
</head>
<body>
<div style="width:100%">

    <!--{include file='comm/menu.tpl'}-->

    <div class="search-box">
        <div style="position:relative">
            <form id="search_form" onsubmit="return false;">
                <table style="width:100%;">
                    <tbody>
                    <tr>
                        <td height="27px">

                            手机：
                            <input type="text" name="mobile" id="mobile" value="" style="width:150px;">
                            &nbsp;

                            投诉类型：
                            <select name="complaintType" id="complaintType" style="width: 150px;">
                                <option value="">请选择</option>
                                <!--{foreach from=$complaintArr item=complaint}-->
                                    <option value="<!--{$complaint->itemID}-->" ><!--{$complaint->itemName}--></option>
                                <!--{/foreach}-->
                            </select>

                            &nbsp;

                            投诉日期：
                            <input type="text" style="width: 100px;" id="startDate" name="startDate" value="" class="clear" readonly="readonly" style="height:26px;">
                            ～
                            <input type="text" style="width: 100px;" id="endDate" name="endDate" value="" class="clear" readonly="readonly" style="height:26px;">

                            &nbsp;

                            <input type="button" class="btn" value="搜索" id="searchBtn" onclick="complaintList.search();">

                            &nbsp;

                            <input type="button" class="btn" value="重置" id="searchBtn" onclick="complaintList.clearUp();">
                        </td>
                    </tr>
                    </tbody>
                </table>
            </form>
        </div>
    </div>

    <table id="flex" style="display:none"></table>

    <!--{include file='comm/footer.tpl'}-->

</div>

<script type="text/javascript">
    $("#flex").flexigrid({
        url:"/invokingAjax-backend/customer/complaint.ajax?operFlg=1",
        dataType: "json",
        colModel : [
            {display: "操作", width : 80, align: "center"},
            {display: "编号", name : "complaintID", width : 80, sortable : true,align:"left"},
            {display: "联系手机", width : 130, align:"left"},
            {display: "投诉时间", width :160 , align:"center"},
            {display: "投诉类型", width : 200 , align:"left"},
            {display: "投诉内容", width : 400 , align:"left"}
        ],
        buttons : [
            {name: "添加", bclass: "add", onpress : "complaintList.add"},
            {separator: true},
            {name: "删除", bclass: "delete", onpress : "complaintList.delcheck"}
        ],
        sortname: "complaintID",
        sortorder: "desc",
        usepager: true,
        rp: 10,
        useRp: true,
        nowrap : false,
        showTableToggleBtn: true,
        onSubmit: function() {
            var dt = $('#search_form').serializeArray();
            $("#flex").flexOptions({params: dt});
            return true;
        }
    });

    var complaintList = {

        delArr: new Array(),

        //删除确认
        delcheck: function(){
            //获取选中的行的行数
            var selected_count = $('.trSelected',flex).length;
            if (selected_count==0) {
                E.alert('请选择要删除的客户投诉');
                return;
            }else{
                var tempArr = new Array();
                for(var i=0; i<selected_count; i++){
                    var complaintIDStr = $('.trSelected',flex).eq(i).attr('id');
                    var complaintID = complaintIDStr.substr(3);
                    tempArr.push(complaintID);
                }
                this.delArr = tempArr;

                //弹出确认层
                E.confirm('确认删除这 ' + $('.trSelected',flex).length + ' 个客户投诉吗?', "complaintList.del");
            }

        },

        del:function(){
            $.ajax({
                type: "POST",
                url: "/invokingAjax-backend/customer/complaint.ajax?operFlg=3",
                dataType: "JSON",
                data:{delArr: complaintList.delArr},
                success: function(result_obj){
                    if (result_obj.code == 200) {
                        E.alert(result_obj.message, 2, "complaintList.load");
                    }
                    else {
                        E.alert(result_obj.message);
                    }
                }
            });
        },

        //搜索
        search: function() {
            var dt = $('#search_form').serializeArray();
            $("#flex").flexOptions({params: dt}).flexReload();
        },

        //添加
        add: function() {
            E.open("/quanliadmin/app/customer/complaint.pscript?operFlg=2");
        },

        //编辑
        edit: function(complaintID) {
            E.open("/quanliadmin/app/customer/complaint.pscript?operFlg=3&id=" + complaintID );
        },

        //订单详情
        billDetail:function( bill_no ){
            E.open("/quanliadmin/app/bill/bill.pscript?operFlg=2&bill_no=" + bill_no, "", {height: 600, width: 1024, top: 10, left: 100});
        },

        detail:function( complaintID ){
            E.open("/quanliadmin/app/customer/complaint.pscript?operFlg=4&id=" + complaintID );
        },

        //重置
        clearUp:function(){
            $("#mobile").val('');
            $("#complaintType").val('');
            $("#startDate").val('');
            $("#endDate").val('');
        },

        load: function() {
            $("#flex").flexReload();
        }

    };


    function jquery_ajax(flg,data,func){
        $.ajax({
            type: "post",
            url: "/invokingAjax-backend/customer/complaint.ajax?operFlg="+flg,
            dataType: "json",
            data: data,
            success: function( result_obj ) {
                func(result_obj);
            },
            error : function(msg){
                alert('网络不给力，请重新尝试...');
            }
        });
    }

    cal.manageFields("startDate", "startDate", "%Y-%m-%d");
    cal.manageFields("endDate", "endDate", "%Y-%m-%d");

</script>

</body>

</html>
